import requests,json,bs4
#抓取携程网站上，关于深圳欢乐谷的前三页评论
msgLink = 'http://you.ctrip.com/destinationsite/TTDSecond/SharedView/AsynCommentView'


maxPage = 3

header = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36'}

topNum  = 1

for page in range(maxPage):
    data = {'poiID':'79101','districtId':'26','districtEName':'Shenzhen','pagenow':str(page+1),'order': '3.0','star': '0.0','tourist':'0.0','resourceId':'13720','resourcetype':'2'}
    msgData = requests.post(msgLink,data,headers=header)
    msgHtml = bs4.BeautifulSoup(msgData.text,'html.parser')
    msgDist = msgHtml.select('.heightbox')
    for text in msgDist:
        print('序号：'+str(topNum)+' 内容：'+text.getText()+"\n\n\n")
        topNum += 1
    page += 1






